﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RBAC.Web.Models;
using RBAC.Web.Service;
using RBAC.Web.Mapper;
using System.Text; 


namespace RBAC.Web.ListCenter
{
    public class GetlistCenter
    {
        private ServiceClient service = new ServiceClient();

		
        internal List<RoleModel> User_RoleList(GetAllRoleRequestDto filterModel)
        {
            var result = new List<RoleModel>();
            var list = service.GetAllRole(filterModel);
            if (list.Data != null && list.Data.Count > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(RoleMapper.DtoToModel(item));
                   
                }
            }
            return result;
        }
		
		 public static string User_RoleMapper(string[] required, RoleModel model)
        {
            StringBuilder result = new StringBuilder();
            result.Append("{");	
			result.Append("\"" + required[0] + "\"" + ":" + "\"" + model.Id + "\"" + ",");
						
						result.Append("\"" + required[1] + "\"" + ":" + "\"" + model.Id + "\"" + ",");

			
						
						
			result.Append("\"" + required[2] + "\"" + ":" + "\"" + model.RoleCode + "\"" );

						result.Append("}");
            return result.ToString();
			}


        internal List<RoleModel> Permission_RoleList(GetAllRoleRequestDto filterModel)
        {
            var result = new List<RoleModel>();
            var list = service.GetAllRole(filterModel);
            if (list.Data != null && list.Data.Count > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(RoleMapper.DtoToModel(item));
                   
                }
            }
            return result;
        }
		
		 public static string Permission_RoleMapper(string[] required, RoleModel model)
        {
            StringBuilder result = new StringBuilder();
            result.Append("{");	
			result.Append("\"" + required[0] + "\"" + ":" + "\"" + model.Id + "\"" + ",");
						
						result.Append("\"" + required[1] + "\"" + ":" + "\"" + model.Id + "\"" + ",");

			
						
						
			result.Append("\"" + required[2] + "\"" + ":" + "\"" + model.RoleCode + "\"" );

						result.Append("}");
            return result.ToString();
			}


        internal List<FunctionModel> Permission_FunctionList(GetAllFunctionRequestDto filterModel)
        {
            var result = new List<FunctionModel>();
            var list = service.GetAllFunction(filterModel);
            if (list.Data != null && list.Data.Count > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(FunctionMapper.DtoToModel(item));
                   
                }
            }
            return result;
        }
		
		 public static string Permission_FunctionMapper(string[] required, FunctionModel model)
        {
            StringBuilder result = new StringBuilder();
            result.Append("{");	
			result.Append("\"" + required[0] + "\"" + ":" + "\"" + model.Id + "\"" + ",");
						
						result.Append("\"" + required[1] + "\"" + ":" + "\"" + model.Id + "\"" + ",");

			
						
						
			result.Append("\"" + required[2] + "\"" + ":" + "\"" + model.FuncName + "\"" );

						result.Append("}");
            return result.ToString();
			}


        internal List<RoleModel> Permission_RoleLookupList(GetAllRoleRequestDto filterModel)
        {
            var result = new List<RoleModel>();
            var list = service.GetAllRole(filterModel);
            if (list.Data != null && list.Data.Count > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(RoleMapper.DtoToModel(item));
                   
                }
            }
            return result;
        }
		
		 public static string Permission_RoleLookupMapper(string[] required, RoleModel model)
        {
            StringBuilder result = new StringBuilder();
            result.Append("{");	
			result.Append("\"" + required[0] + "\"" + ":" + "\"" + model.Id + "\"" + ",");
						
						result.Append("\"" + required[1] + "\"" + ":" + "\"" + model.Id + "\"" + ",");

			
						
						
			result.Append("\"" + required[2] + "\"" + ":" + "\"" + model.RoleCode + "\"" );

						result.Append("}");
            return result.ToString();
			}


        internal List<DomainModel> Function_DomainList(GetAllDomainRequestDto filterModel)
        {
            var result = new List<DomainModel>();
            var list = service.GetAllDomain(filterModel);
            if (list.Data != null && list.Data.Count > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(DomainMapper.DtoToModel(item));
                   
                }
            }
            return result;
        }
		
		 public static string Function_DomainMapper(string[] required, DomainModel model)
        {
            StringBuilder result = new StringBuilder();
            result.Append("{");	
			result.Append("\"" + required[0] + "\"" + ":" + "\"" + model.Id + "\"" + ",");
						
						result.Append("\"" + required[1] + "\"" + ":" + "\"" + model.Id + "\"" + ",");

			
						
						
			result.Append("\"" + required[2] + "\"" + ":" + "\"" + model.DomainName + "\"" );

						result.Append("}");
            return result.ToString();
			}


        internal List<DomainModel> Function_DomainLookupList(GetAllDomainRequestDto filterModel)
        {
            var result = new List<DomainModel>();
            var list = service.GetAllDomain(filterModel);
            if (list.Data != null && list.Data.Count > 0)
            {
                foreach (var item in list.Data)
                {
                    result.Add(DomainMapper.DtoToModel(item));
                   
                }
            }
            return result;
        }
		
		 public static string Function_DomainLookupMapper(string[] required, DomainModel model)
        {
            StringBuilder result = new StringBuilder();
            result.Append("{");	
			result.Append("\"" + required[0] + "\"" + ":" + "\"" + model.Id + "\"" + ",");
						
						result.Append("\"" + required[1] + "\"" + ":" + "\"" + model.Id + "\"" + ",");

			
						
						
			result.Append("\"" + required[2] + "\"" + ":" + "\"" + model.DomainName + "\"" );

						result.Append("}");
            return result.ToString();
			}


	}
}